<?php

/**
 * @copyright since 7:51 20/4/2020
 * @author <mc@dancis.info>
 */

require '../vendor/autoload.php';

function str1($str)
{
    $func_list = [
        'strtolower',
        'strtoupper',
    ];

    foreach ($func_list as &$func_run) {
        disp($func_run($str));
    }
}

function str2($str)
{
    disp(str_replace([
        '+',
        '-',

        ' ',
        "'",
    ], [
        '\+',
        '\-',

        '+',
        '-',
    ], $str));
}

function str3($arr)
{
    list($str3a, $str3b, $str3c) = $arr;
    $process = [
        'str3a' => 'ltrim',
        'str3b' => 'rtrim',
        'str3c' => 'trim',
    ];
    foreach ($process as $var => &$func) {
        disp('[' . $func($$var) . ']');
    }
}

(function () {
    str1('Learn PHP string related functions online.');

    disp('');
    str2('Here\'s a string.');

    disp('');
    str3([
        ' 18 Software - Class 5,6 ',
        ' 18 Software - Class 7,8 ',
        ' 18 Software - Class 5,6,7,8 ',
    ]);
})();
